package com.example.dzl.util;

public class BaseResult<T> {

    private int statusCode;  // 状态码
    private String message;   // 响应消息
    private T data;           // 响应数据

    public BaseResult(int statusCode, String message, T data) {
        this.statusCode = statusCode;
        this.message = message;
        this.data = data;
    }

    // Getter 和 Setter 方法
    public int getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    // 静态方法帮助构建结果
    public static <T> BaseResult<T> success(T data) {
        return new BaseResult<>(200, "Success", data);
    }

    public static <T> BaseResult<T> error(String message) {
        return new BaseResult<>(500, message, null);
    }
}
